package com.baige.facade.message;

import com.baige.common.exception.MessageBizException;
import com.baige.facade.dto.TransactionMessageDTO;

/**
 * 事务消息--facade
 * @author wulg
 * @date 2018/12/12.
 */
public interface TransactionMessageFacade
{

    /**
     * 预存储消息
     * @param transactionMessageDTO 预存储对象
     * @return int
     * @throws MessageBizException 消息业务异常
     */
    int saveMessageWaitingConfirm(TransactionMessageDTO transactionMessageDTO) throws MessageBizException;


    /**
     * 确认并发送消息
     * @param messageId 消息id
     * @throws MessageBizException 消息业务异常
     */
    void confirmAndSendMessage(String messageId) throws MessageBizException;


    /**
     * 存储并发送消息
     * @param transactionMessageDTO 存储对象
     * @return int
     * @throws MessageBizException 消息业务异常
     */
    int saveAndSendMessage(TransactionMessageDTO transactionMessageDTO) throws MessageBizException;


    /**
     * 直接发送消息
     * @param transactionMessageDTO 存储对象
     * @throws MessageBizException 消息业务异常
     */
    void directSendMessage(TransactionMessageDTO transactionMessageDTO) throws MessageBizException;


    /**
     * 重发消息
     * @param transactionMessageDTO 存储对象
     * @throws MessageBizException 消息业务异常
     */
    void reSendMessage(TransactionMessageDTO transactionMessageDTO) throws MessageBizException;


    /**
     * 根据messageId重发某条消息.
     * @param messageId 消息id
     * @throws MessageBizException 消息业务异常
     */
    void reSendMessageByMessageId(String messageId) throws MessageBizException;


    /**
     * 将消息标记为死亡消息
     * @param messageId 消息id
     * @throws MessageBizException 消息业务异常
     */
    void setMessageToAreadlyDead(String messageId) throws MessageBizException;


    /**
     * 根据消息ID获取消息
     * @param messageId 消息id
     * @return TransactionMessageDTO
     * @throws MessageBizException 消息业务异常
     */
    TransactionMessageDTO getMessageByMessageId(String messageId) throws MessageBizException;

    /**
     * 根据消息ID删除消息
     * @param messageId 消息id
     * @throws MessageBizException 消息业务异常
     */
    void deleteMessageByMessageId(String messageId) throws MessageBizException;

}
